package com.xxh.dasongapp.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
@Slf4j
public class FileUploadConfig implements WebMvcConfigurer {

    public void addResourceHandlers(ResourceHandlerRegistry registry) {

        //获取文件的真实路径
        String path = System.getProperty("user.dir")+"/upload/img/";
        log.info("uploadFilePath:"+path);
        registry.addResourceHandler("/img/**")
                .addResourceLocations("file:"+path);
    }
}